﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows;
using MySql.Data.MySqlClient;
//111
namespace TicketManagement
{
    public partial class WebForm1 : System.Web.UI.Page
    {

        protected void TextBox2_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            int username = int.Parse(this.username.Text);
            string password = this.password.Text;
            int identity = 0;

            if (identity_table.SelectedValue == "管理员")
            {
                identity = 1;
            }
            else if (identity_table.SelectedValue == "分销商")
            {
                identity = 2;
            }
            string connStr = "server=121.43.119.97;user id=root;password=h666niub;persistsecurityinfo=True;database=ticket_management_system";
            MySqlConnection conn = new MySqlConnection(connStr);
            conn.Open();
            try
            {
                

                string insertStr = "INSERT INTO  user(username,password,identity_id) VALUES (" + username + "," + password + "," + identity + ")";
                MySqlCommand cmd = new MySqlCommand(insertStr, conn);

                //通过sql语句对表添加数值

                if (Convert.ToInt32(cmd.ExecuteScalar()) > 0)
                {
                    MessageBox.Show("登录成功！");
                    /*this.DialogResult = DialogResult.OK;
                      this.Dispose();
                      this.Close();*/
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString() + "打开数据库失败");
            }
        }
    }
}